package cn.mesmile.video.controller;

import cn.mesmile.daomain.Video;
import cn.mesmile.video.service.VideoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 * @author zb
 * @version 1.0
 * @date 2020/10/24 12:06
 * @description 视频服务视图层
 */
@RestController
@RequestMapping("/api/v1/video")
public class VideoController {

    private final VideoService videoService;

    public VideoController(VideoService videoService) {
        this.videoService = videoService;
    }

    @GetMapping("/getVideoById")
    public Object getVideoById (@RequestParam("videoId")Integer videoId, HttpServletRequest request){
        Video video = videoService.getVideoById(videoId);
        // 查看是哪个服务调用的
        video.setServerInfo(request.getServerName() + ":" + request.getServerPort());
        return video;
    }

}
